-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Support [DataMember] IsRequired in NewtonsoftDataContractResolver #2644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thanks for contributing - if you'd like to continue with this pull request, please rebase against the default branch to pick up our new CI. We'd also require tests for this scenario. |
|
I'll rebase once #2799 is merged |
|
FYI #2799 was merged a month ago. |
src/Swashbuckle.AspNetCore.Newtonsoft/SchemaGenerator/JsonPropertyExtensions.cs
Show resolved
Hide resolved
test/Swashbuckle.AspNetCore.Newtonsoft.Test/Fixtures/JsonPropertyAnnotatedType.cs
Outdated
Show resolved
Hide resolved
test/Swashbuckle.AspNetCore.Newtonsoft.Test/Fixtures/JsonRequiredAnnotatedType.cs
Show resolved
Hide resolved
As DataMember implementation comes after the implementation for [JsonProperty] and [JsonObject], we want to be sure that the current behavior is not bypassed.
Add test cases for DataMember (IsRequired and Name). It seems that NewtonSoft's ResolveContract correctly set the Required, using [DataMember], [JsonProperpty] and [JsonRequired] so we can directly use it instead of the IsRequiredSpecifed extension method.
Newtonsoft do all the work for us, handling [JsonProperty(Required = Required.Always)] or [JsonRequired] or [DataMember(IsRequired = true)] and filling the JsonProperty.Required field.
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #2644 +/- ##
==========================================
+ Coverage 88.46% 90.61% +2.14%
==========================================
Files 95 74 -21
Lines 3364 2962 -402
Branches 577 469 -108
==========================================
- Hits 2976 2684 -292
+ Misses 388 278 -110
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
Thanks! |
|
Version 6.7.1 is now available from NuGet.org which includes this change. |
Resolves #2383